package com.example.administrator.activityxml;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.content.Intent;


public class otherActivity extends Activity {
    private Intent intent = new Intent();
    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.other);
        //getIntent()是获得启动该活动的Intent对象，getExtras()是获得一个Bundel对象
        Bundle bundle = this.getIntent().getExtras();
        //获取bundle对象中的数据
        String ans = bundle.getString("ans");
        String sexText;
        if (ans.equals("in")) {
            sexText = "您的答案是正确的";
        }
        else {
            sexText = "您的答案是错误的";
        }
        TextView tv1 = (TextView) findViewById(R.id.text1);
        tv1.setText("您选择的答案是："+ans+"    "+sexText);

        //利用findViewById获取Button按钮的对象button_back
        //然后对它设置事件监听器，添加点击事件的OnClickListener接口
        Button btn3_back = (Button) findViewById(R.id.button_back);
        btn3_back.setOnClickListener(new Button.OnClickListener(){
            @Override
            public void onClick(View v){
                otherActivity.this.setResult(RESULT_OK,intent);
                otherActivity.this.finish();
            }
        });
    }

}
